﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LotteryVote.Entity;
using System.Data.SqlClient;

namespace LotteryVote.Data
{
    public class ConcreteCommissionDataAccess : DataBase
    {
        public void InsertConcreteCommission(ConcreteCommission concreteComm)
        {
            string sql = string.Format(@"INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES (@{1},@{2},@{3},@{4},@{5})",
                ConcreteCommission.TABLENAME, ConcreteCommission.GROUPID, ConcreteCommission.GAMEID, ConcreteCommission.COMPANYTYPEID,
                ConcreteCommission.COMMISSION, ConcreteCommission.ODDS);
            base.ExecuteNonQuery(sql, new SqlParameter(ConcreteCommission.GROUPID, concreteComm.Group.GroupId),
                new SqlParameter(ConcreteCommission.GAMEID, concreteComm.GameType.GameId),
                new SqlParameter(ConcreteCommission.COMPANYTYPEID, concreteComm.CompanyType.Id),
                new SqlParameter(ConcreteCommission.COMMISSION, concreteComm.Commission),
                new SqlParameter(ConcreteCommission.ODDS, concreteComm.Odds));
        }

        public void ClearConcreteCommission(int groupId)
        {
            string sql = string.Format(@"DELETE {0} WHERE {1}=@{1}", ConcreteCommission.TABLENAME, ConcreteCommission.GROUPID);
            base.ExecuteNonQuery(sql, new SqlParameter(ConcreteCommission.GROUPID, groupId));
        }

    }
}
